// 防抖函数
function debounce (fn, delay) {
  let timer = null
  return function () {
    if (timer) {
      clearTimeout(timer)
      timer = null
    } else {
      timer = setTimeout(fn, delay)
    }
  }
}

// 下载文件
function downloadUrl (blob, name, type) {
  const fileName = name + `.${type}` // 导出文件名
  const elink = document.createElement('a') // 创建a标签
  elink.download = fileName // a标签添加属性
  elink.style.display = 'none'
  elink.href = URL.createObjectURL(blob)
  document.body.appendChild(elink)
  elink.click() // 执行下载
  URL.revokeObjectURL(elink.href) // 释放URL 对象
  document.body.removeChild(elink) // 释放标签
}

const Test = class {
  @log
  add (a, b) {
    return a + b
  }
}
function log (target, name, descritor) {
  let oldValu = descritor.value
  descritor.value = function () {
    console.log(this, '这个this是什么东西')
    return oldValu.apply(this, arguments)
  }
  // console.log(target, name, descritor)
}

export {
  Test,
  debounce,
  downloadUrl
}
